package com.itheima.upload.banben5;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/*
服务端
接收上传的文件 保存到服务端的本地
给客户端上传成功的结果
服务器需要可以支持不断的上传

之前上传的图片也想保留
多线程优化
线程想要从线程池中获取
 */
public class Server5 {
    public static void main(String[] args) throws IOException {
        //创建服务端对象 ss
        ServerSocket ss = new ServerSocket(18888);
        //创建线程池
        ExecutorService pool = Executors.newCachedThreadPool();
        //接收客户端连接 ss.accept(); 获取对象 accept
        while (true) {
            Socket accept = ss.accept();
            MyRunable my = new MyRunable(accept);
            pool.submit(my);
        }
        //ss.close();


    }


}
